fix: add pytest plugin for caplog integration#97
Merged
Conversation
- Create pytest plugin that forwards loguru logs to caplog fixture - Register plugin as pytest11 entry point so it loads automatically - Bypass standard logging to avoid recursion with InterceptHandler - Support caplog level filtering via at_level() context manager - Add comprehensive tests for caplog integration Closes the issue where logs output via logprise don't show up in caplog.
…/fix-logprise-logcap-S5zBD
Type the loguru sink parameter as loguru.Message and the record helper as loguru.Record instead of object/dict. This removes the incorrect 'type: ignore[union-attr]' comment (mypy reported attr-defined) that was failing the stubtest lint step in CI, and cast the loguru RecordException to the exc_info type expected by logging.LogRecord.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #97 +/- ##
===========================================
- Coverage 99.50% 72.57% -26.94%
===========================================
Files 1 2 +1
Lines 203 237 +34
Branches 35 37 +2
===========================================
- Hits 202 172 -30
- Misses 0 63 +63
- Partials 1 2 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The logprise pytest plugin (pytest11 entry point) already forces logprise to load at pytest startup, so the per-test inline imports provided no lazy-loading benefit and only triggered ruff PLC0415. Move the single import to the module top level.
- Add a direct test for the sink's no-fixture early-return branch. - Reload the plugin module once via a session-scoped autouse fixture so its import-time definitions (loaded at pytest startup, before coverage begins) are measured. - Add codecov.yml requiring 100% patch coverage on every change, with project coverage held at no-regression.
- Add a 'Testing with caplog' section explaining the auto-loaded pytest plugin that surfaces loguru/logprise logs in pytest's caplog fixture. - Add PyPI version, Python versions, build, codecov coverage and license badges to the README header.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #94 : logs output via logprise don't show up in caplog.